import { createSlice } from '@reduxjs/toolkit';

interface State {
  userId: number;
  vip: number;
  userType: 'qq' | '';
  username: string;
  avatar: string; // 头像
  bind_phone: number; // 是否绑定手机号 1-已绑定 0-未绑定
}

const initialState: State = {
  userId: -1,
  vip: -1,
  userType: '',
  username: '',
  avatar: '',
  bind_phone: 0,
};
export const counterSlice = createSlice({
  name: 'userInfo',
  initialState: {
    ...initialState,
  },
  reducers: {
    setUserInfo: (state, action) => {
      Object.assign(state, action.payload);
    },
    setBindPhone(state, action) {
      state.bind_phone = action.payload;
    },
  },
});
const userInfoReducer = counterSlice.reducer;
const userInfoAction = counterSlice.actions;
export { userInfoReducer, userInfoAction };
